﻿using UnityEngine;
using System.Collections;

public class MailMessageCell : MonoBehaviour
{
	public int indexPath;
	public EPCheckBox checkBox;	
	public UILabel titleLabel;
	public UILabel contentLabel;
	public UILabel receiveDateLabel;
	public UILabel remainTimeLabel;


	void OnEnable()
	{
		animation["View_message Open"].time = 0.0f; 
		animation["View_message Open"].enabled = true;
		animation.Sample();
		animation["View_message Open"].enabled = false;
	}

	public void OnClick_WriteInAnswer()
	{
		this.GetComponent<UIDragScrollView>().scrollView.GetComponent<MailMessageScrollView>().sceneManager.OnClick_WriteMessageTabWithIndexPath(indexPath);
	}

	public void OnClick_MessageFlipOpen()
	{
		this.GetComponent<UIDragScrollView>().scrollView.GetComponent<MailMessageScrollView>().sceneManager.FlipOpenMailMessageCell(indexPath);
	}

	public void OnClick_MessageFlipClose()
	{
		this.GetComponent<UIDragScrollView>().scrollView.GetComponent<MailMessageScrollView>().sceneManager.FlipCloseMailMessageCell(indexPath);
	}

	public void OnCheckBoxButton()
	{
		// 주의 : 초기에는 scrollView 값이 세팅되지 않음
		if (this.GetComponent<UIDragScrollView>() == null)
			return;

		else if (this.GetComponent<UIDragScrollView>().scrollView == null)
			return;

		this.GetComponent<UIDragScrollView>().scrollView.GetComponent<MailMessageScrollView>().sceneManager.SetMailMessageCheckBox(indexPath, checkBox.IsChecked);
	}
}